﻿using SS.WPF.Framework.Markup;

namespace SS.WPF.Toolkit.PropertyEditor.Resource
{
    using System.Collections.Generic;
    using System.Windows.Controls;

    public partial class Templates
    {
        public Templates()
        {
            this.InitializeComponent();
        }

        private void Items_OnLoadingRow(object sender, DataGridRowEventArgs e)
        {
            e.Row.Header = (e.Row.GetIndex() + 1).ToString();
        }

        public static DataGridRow GetRow(DataGrid grid, int index)
        {
            var row = (DataGridRow)grid.ItemContainerGenerator.ContainerFromIndex(index);
            if (row == null)
            {
                // May be virtualized, bring into view and try again.
                grid.UpdateLayout();
                grid.ScrollIntoView(grid.Items[index]);
                row = (DataGridRow)grid.ItemContainerGenerator.ContainerFromIndex(index);
            }

            return row;
        }
    }

    public static class BoolValues
    {
        public static IList<EnumPair> Items
        {
            get
            {
                return new List<EnumPair>()
                    {
                        new EnumPair("No", false),
                        new EnumPair("Yes", true),
                    };
            }
        }
    }
}